package com.gjy.sb.service.impl;

import com.gjy.sb.domain.jpa.Book;
import com.gjy.sb.domain.jpa.User;
import com.gjy.sb.repository.BookRepository;
import com.gjy.sb.repository.UserRepository;
import com.gjy.sb.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-03-12 08:33:05
 */
@Service
@Transactional(rollbackFor = RuntimeException.class)
public class UserServiceImpl implements UserService {

    @Resource
    private UserRepository userRepository;
    @Resource
    private BookRepository bookRepository;

    public final void saveUser() {
        userRepository.save(new User(null, "gjy", 24));
        bookRepository.save(new Book(null, "三国演义", new BigDecimal("30.24")));
        throw new RuntimeException();
    }

}
